Skip to content

Add NSF batch record creation with 1000-record API limit#211

Open
mtyagi-ks wants to merge 3 commits into
nsf-record-add-batchfrom
nsf-record-add-batch-int
Open

Add NSF batch record creation with 1000-record API limit#211
mtyagi-ks wants to merge 3 commits into
nsf-record-add-batchfrom
nsf-record-add-batch-int

Conversation

@mtyagi-ks

@mtyagi-ks mtyagi-ks commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add batch NSF record creation to the SDK, aligned with Commander's create_records_batch_v3 behavior (up to 1000 records per vault/records/v3/add request).
  • Introduce create_nsf_records_batch() for a single API batch, create_nsf_records() for larger bulk loads with automatic chunking, and NsfRecordAddSpec for typed batch specs.
  • Refactor create_nsf_record() to use the shared batch add path (single-record behavior unchanged).
  • Add nsf-record-add --batch-file CLI support for JSON-driven bulk creation in scripts.
  • Add unit tests and update the SDK example for batch usage.

Changes

SDK (nsf_management.py)

  • NSF_RECORD_ADD_BATCH_LIMIT = 1000
  • NsfRecordAddSpec — dataclass for one record in a batch
  • create_nsf_records_batch() — 1–1000 records in one API call
  • create_nsf_records() — any count; auto-chunks into 1000-record requests
  • create_nsf_record() — delegates to batch path internally

CLI (nsf_commands.py)

  • New --batch-file FILE flag on nsf-record-add
  • Accepts a JSON array of record definitions (title, record_type, folder/folder_uid, fields, notes, record_data)
  • Reports per-record success/failure and a final summary (created / failed / total)

Tests & examples

  • unit_tests/test_nsf_record_add_batch.py — batch limit, chunking, failure handling
  • examples/sdk_examples/nested_shared_folders/nsf_record_add.py — batch example

Test plan

  • Unit tests: python -m unittest unit_tests.test_nsf_record_add_batch (5/5 pass)
  • Manual — small batch (3 records) via --batch-file
  • Manual — large batch (1002 records) via --batch-file
    • Result: 1002 created, 0 failed, 1002 total (2 API batches: 1000 + 2)
  • Verify records in vault: nsf-list --records, nsf-get "NSF Batch Test Login 0001"

Usage

CLI:

nsf-record-add --batch-file records.json

[
  {
    "title": "My Login",
    "record_type": "login",
    "folder": "BatchTest",
    "fields": {
      "login": "user@example.com",
      "password": "secret"
    }
  }
]

@mtyagi-ks mtyagi-ks requested a review from adeshmukh-ks July 9, 2026 09:01
@adeshmukh-ks adeshmukh-ks requested a review from sali-ks July 9, 2026 09:21
Comment thread examples/sdk_examples/nested_shared_folders/nsf_record_add.py Outdated
Comment thread keepersdk-package/src/keepersdk/vault/nsf_management.py
Comment thread keepersdk-package/src/keepersdk/vault/nsf_management.py
Comment thread keepersdk-package/src/keepersdk/vault/nsf_management.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants